<template>
    <div id="baseInfo">
        <el-breadcrumb separator="/">
            <el-breadcrumb-item>基本信息</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card class="box-card">
            <el-row :gutter="20">
                <el-col :span="this.$store.state.elColNum">
                    <el-form ref="form" :model="form" :label-width="this.$store.state.setLabelWidth" size="small">
                        <el-form-item label="作者姓名">
                            <el-col :span="15">
                                <el-input v-model="form.name"></el-input>
                            </el-col>
                        </el-form-item>
                        <el-form-item label=笔名>
                            <el-col :span="15">
                                <el-input v-model="form.pen_name"></el-input>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="邮箱">
                            <el-col :span="15">
                                <el-input v-model="form.mail"></el-input>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="手机号">
                            <el-col :span="15">
                                <el-input v-model="form.phone"></el-input>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="剩余金币">
                            <el-col :span="15">
                                <el-input v-model="form.coin" disabled></el-input>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="提现方式">
                            <el-col :span="15">
                                <el-select v-model="form.withdraw_type" placeholder="提现方式" disabled
                                           :class="this.$store.state.windowWidth<=this.$store.state.MaxWidth?'maxWidth':''">
                                    <el-option label="微信" value="1"></el-option>
                                    <el-option label="支付宝" value="2"></el-option>
                                </el-select>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="提现姓名">
                            <el-col :span="15">
                                <el-input v-model="form.withdraw_name" disabled></el-input>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="提现账号">
                            <el-col :span="15">
                                <el-input v-model="form.withdraw_account" disabled></el-input>
                            </el-col>
                        </el-form-item>
                        <el-form-item label="提现金币">
                            <el-col :span="15">
                                <el-input v-model="coin"></el-input>
                            </el-col>
                            <el-button type="primary" @click="withdraw">申请提现</el-button>
                        </el-form-item>
                        <el-form-item>
                            <el-col :span="15">
                                <el-button type="primary" @click="onSubmit">修改</el-button>
                            </el-col>
                        </el-form-item>
                    </el-form>
                </el-col>
            </el-row>
        </el-card>
    </div>
</template>

<script>
  export default {
    name: "baseInfo",
    data() {
      return {
        form: {},
        coin: '',
      }
    },
    created() {
      this.getUserInfo();
    },
    methods: {
      getUserInfo() {
        this.$axios.post('writer/writer/get_info').then((res) => {
          this.form = res.data;
        });
      },
      onSubmit() {
        this.$axios.post('writer/writer/update', this.form).then((res) => {
          this.$message.success('成功');
          this.getUserInfo();
        });
      },
      withdraw() {
        this.$axios.post("writer/withdraw/apply", {coin: this.coin}).then((res) => {
          this.$message.success('申请成功!');
          this.getUserInfo();
        })
      }
    }
  }
</script>

<style scoped>

</style>